package com.cap5.config;

import com.cap1.Person;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

@Configuration
public class Cap5MainConfig {
    @Bean("person")//bean在IOC容器中的ID
    public Person person() {
        System.out.println("给容器中添加----person----");
        return new Person("james", 20);
    }

    @Conditional(WinCondition.class)//条件加载
    @Bean("lison")
    public Person lison() {
        System.out.println("给容器中添加----lison----Win环境");
        return new Person("lison", 58);
    }

    @Conditional(LinCondition.class)
    @Bean("james")
    public Person james() {
        System.out.println("给容器中添加----james----Linux环境");
        return new Person("james", 200);
    }
}
